package com.demo.connectdbtest.module.dict.meMapper;

import com.demo.connectdbtest.module.dict.domain.StatGoldConsumeStatistics;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

//@Mapper
public interface StatGoldConsumeStatisticsMapper {


    @Select("select id, uid, uuid, total_consume_gold, create_time, update_time from stat_gold_consume_statistics where uid in " +
            "<foreach collection = 'list' item = 'item' open = '(' close = ')' separator = ','>" +
            "#{item}"+
            "</foreach>")
    List<StatGoldConsumeStatistics> listConsumeRecordByBatchUid(@Param("list") List<Long> uidList);

    @Insert("<script>" +
            "insert into stat_gold_consume_statistics (uid, uuid, total_consume_gold, create_time) "+
            "values "+
            "<foreach item = 'data' index = 'index' collection = 'list' separator = ',' close = ';'>" +
            "(#{data.uid}, #{data.uuid}, #{data.totalConsumeGold}, #{data.createTime})"+
            "</foreach>"+
            "</script>")
    void addBatchConsumeRecord(@Param("list") List<StatGoldConsumeStatistics> addList);

  @Update({"<script> " +
          "<foreach collection='list' index='index' item='item' separator=';'> " +
          "UPDATE stat_gold_consume_statistics SET " +
          "total_consume_gold = #{item.totalConsumeGold}, " +
          "update_time = #{item.updateTime} " +
          "WHERE `uid`= #{item.uid} " +
          "</foreach>" +
          "</script>"})
    void updateBatchConsumeByUid(@Param("list")List<StatGoldConsumeStatistics> updateList);
}
